﻿using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        /// <summary>
        /// GetJob is used to collect the tasks to finish the order creation
        /// </summary>
        /// <param name="FInterID"></param>
        /// <returns></returns>
        public DataSet YCCLABEL(DataSet db)
        {

            DataSet Result = new DataSet();
            DataSet Return = new DataSet();
            string TXTISIND = "", VAART = "", WAFBRTL = "", WAFBRTU = "", WARGRLFD = "", WIDTH = "", WAFGRQM = "";
            try
            {
                string CellValue = "";
                Helpers.Helper.GetDate(ref date, ref year, ref month, ref day);
                foreach (DataRow dwData in db.Tables["VAART"].Rows)
                {
                    /*TXTISIND = Helper.Left("00000000      " + dwData["VAADART"].ToString() + dwData["VAADVAR"].ToString().PadRight(60), 60);
                    if (db.Tables.Contains("TXTKON"))
                    {
                        var query = from DataRow row in db.Tables["TXTKON"].AsEnumerable()
                                    where row["TXTISIND"].ToString() == TXTISIND
                                    && row["TXTITXTART"].ToString() == "WFT"
                                    select row;
                        foreach (DataRow row in query)
                        {
                            switch (row["TXTKATR"].ToString())
                            {
                                case "0"://普通备注
                                    break;
                                case "1"://经纬纱
                                    CellValue = Helper.GetGB2312Value(row["TXTKTEXT"].ToString()).Trim();
                                    //exAgent.SetCellValue(5, 2, CellValue);
                                    break;
                                case "2"://成份
                                    CellValue = Helper.GetGB2312Value(row["TXTKTEXT"].ToString()).Trim();
                                    exAgent.SetCellValue(5, 2, CellValue);
                                    break;
                            }
                        }
                    }*/
                    VAART = dwData["VAADART"].ToString();
                    if (db.Tables.Contains("WASTAMM"))
                    {
                        var query = from DataRow row in db.Tables["WASTAMM"].AsEnumerable()
                                    where row["WAART"].ToString() == VAART
                                    select row;
                        foreach (DataRow row in query)
                        {
                            WAFBRTL = row["WAFBRTL"].ToString().Trim();
                            WAFBRTU = row["WAFBRTU"].ToString().Trim();
                            if (WAFBRTL == "0")
                            {
                                WIDTH = WAFBRTU + " CM";
                            }
                            else
                            {
                                WIDTH = WAFBRTL + " CM(CUT)-" + WAFBRTU + " CM";
                            }
                            exAgent.SetCellValue(5, 5, WIDTH);
                            WARGRLFD = row["WAFGRLFD"].ToString().Trim();
                            exAgent.SetCellValue(6, 5, WARGRLFD+" G/M");
                            WAFGRQM = row["WAFGRQM"].ToString().Trim();
                            exAgent.SetCellValue(6, 8, WAFGRQM + " G/M2");
                        }
                    }
                    CellValue = dwData["VAAART"].ToString();
                    exAgent.SetCellValue(1, 5, CellValue);
                    CellValue = dwData["VAABEZ"].ToString();
                    exAgent.SetCellValue(2, 5, CellValue);
                    CellValue = dwData["VAAFILLER"].ToString();
                    exAgent.SetCellValue(3, 5, CellValue);
                    //CellValue = dwData["VAABRTVON"].ToString();
                    //exAgent.SetCellValue(8, 5, Helper.Times(CellValue, 0.01));
                    //CellValue = dwData["VAAGEWVON"].ToString();
                    //exAgent.SetCellValue(9, 5, Helper.Times(CellValue, 0.01));
                    exAgent.SetCellValue(7, 5, date);
                    //CellValue = "*" + dwData["VAAART"].ToString().Trim() + "*";
                    //exAgent.SetCellValue(11, 1, CellValue);
                }
                exAgent.Save();
                exAgent.FileName = DestFile;
                DirectPrint(DestFile, COPYS);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {

            }
            return Return;
        }

    }
}
